package com.addcn.android.design591.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.addcn.android.design591.R;

import java.util.ArrayList;

/**
 * Created by xuge on 2017/1/18.
 * 下拉框适配器
 */

public class SpinnerCityAdatper extends ArrayAdapter<String> {
    private Context context;

    public SpinnerCityAdatper(Context context, int spinner_item, ArrayList<String> arrayList_city) {
        super(context, spinner_item, arrayList_city);
        this.context = context;
    }


    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView textView = (TextView) convertView;
        if (textView == null) {
            LayoutInflater layoutInflater = LayoutInflater.from(context);
            textView = (TextView) layoutInflater.inflate(R.layout.spinner_item, null);
        }
        String value = getItem(position);
        textView.setText(value);
        return textView;
    }
}
